package com.example.firststory;

import java.util.Locale;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

public class Inicio extends FragmentActivity {

	ViewPager pager = null;
	
	public Button empezar;

	MyFragmentPagerAdapter pagerAdapter;
	Intent traspaso;

	protected void onCreate(Bundle arg0) {

		super.onCreate(arg0);
		this.setContentView(R.layout.activity_inicio);
		
		empezar = (Button) findViewById(R.id.empezar);
		this.pager = (ViewPager) this.findViewById(R.id.pager);

		MyFragmentPagerAdapter adapter = new MyFragmentPagerAdapter(
				getSupportFragmentManager());

		adapter.addFragment(InicioSlidePageFragment
				.newInstance(R.drawable.ciudad));
		adapter.addFragment(InicioSlidePageFragment
				.newInstance(R.drawable.nino));
		adapter.addFragment(InicioSlidePageFragment.newInstance(R.drawable.mom));

		this.pager.setAdapter(adapter);

		listenerEmpezar();
	}

	public void onNewIntent(Intent data) {

		this.pager.setCurrentItem(0);
	}

	public void onBackPressed() {

		if (this.pager.getCurrentItem() == 0)
			super.onBackPressed();
	}

	public void listenerEmpezar() {

		empezar.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {

				setActivity();
				startActivity(traspaso);

			}
		});
	}

	public void setActivity() {

		traspaso = new Intent(this, SeleccionarHistoria.class);

	}

	public void cambiarActivity() {

		traspaso.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
		startActivity(traspaso);

	}

}